<?php 
namespace app\model;

use think\model;
use think\facade\Cache;
use think\facade\Db;

class TableModel extends Model 
{
    // 设置当前模型对应的完整数据表名称
    protected $table = 'table';
    // 设置当前模型的数据库连接
    //protected $connection = 'db_config';
    //protected $pk = 'id';

    // 模型初始化
    protected static function init()
    {
        //TODO:初始化内容
    }

    public function getAll(){
        $list=Cache::get('tables');
        if(!$list){
            $list=[];
            $table = $this->select()->toArray();
            foreach($table as $k=>$v){
                $list[$v['id']]=$v;
            }
            Cache::set('tables',$list,300);
        }
        return $list;
      
    }

}

